<?php
/**
 * Created by PhpStorm.
 * User: wuxiaojie
 * Date: 2018/7/25
 * Time: 21:33
 */

if (! defined('IN_ANWSION'))
{
die();
}

class aomas_tools extends AWS_ADMIN_CONTROLLER{



    public  function  build_qrcode_action()
    {
//        $this->crumb(AWS_APP::lang()->_t('添加专题'), 'admin/aomas_tools/add');
//        TPL::assign('menu_list', $this->model('admin')->fetch_menu_list(502));

        header('Location: http://www.liantu.com/');
        die();

    }


    public  function  upload_media_action()
    {

        if ($_POST['action'] == 'search')
        {
            foreach ($_POST as $key => $val)
            {
                if (in_array($key, array('goods_name')))
                {
                    $val = rawurlencode($val);
                }

                $param[] = $key . '-' . $val;
            }

            H::ajax_json_output(AWS_APP::RSM(array(
                'url' => get_js_url('/admin/aomas_tools/upload_media/' . implode('__', $param))
            ), 1, null));
        }

                $this->crumb(AWS_APP::lang()->_t('上传'), 'admin/aomas_tools/upload_list');

                TPL::assign('menu_list', $this->model('admin')->fetch_menu_list(503));

                TPL::import_js(array(
                    'js/fileupload.js',
                ));

        $where = array();

        $where[]="item_type = 'global'";
        if (trim($_GET['file_name'])) {
            $where[] = "file_name LIKE '%" . $this->model('goods')->quote($_GET['file_name']) . "%'";
        }

        $attach_list = $this->model('goods')->fetch_page('attach', implode(' AND ', $where), 'id DESC', $_GET['page'], $this->per_page);

        $total_rows = $this->model('goods')->found_rows();

        $url_param = array();

        foreach ($_GET as $key => $val) {
            if (!in_array($key, array('app', 'c', 'act', 'page'))) {
                $url_param[] = $key . '-' . $val;
            }
        }
        TPL::assign('pagination', AWS_APP::pagination()->initialize(array(
            'base_url' => get_js_url('/admin/aomas_tools/upload_media/') . implode('__', $url_param),
            'total_rows' => $total_rows,
            'per_page' => $this->per_page
        ))->create_links());


        TPL::assign('list', $attach_list);
        TPL::assign('total_rows', $total_rows);



        TPL::output('admin/aomas_tools/upload_list');

    }
}